//
//  ChooseView.m
//  KuWoCan
//
//  Created by LiBenCan on 17/9/26.
//  Copyright © 2017年 hwd. All rights reserved.
//

#import "ChooseView.h"

@implementation ChooseView

-(instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame])
    {
        self.backgroundColor = [UIColor whiteColor];
        [self CreatUI];
    }
    return self;
}
-(void)CreatUI//构建视图
{
    [self addSerchView];
    [self addSubview:self.nameText];
    [self addSubview:self.lianXiText];
    [self addSubview:self.phoneText];
    [self addSubview:self.addressText];
}

-(TextFiledView *)nameText//客户姓名
{
    if (!_nameText) {
        _nameText = [[TextFiledView alloc]initWithFrame:CGRectMake(35*screenW_6,25*screenW_6,SCREENW-70*screenW_6, 40*screenW_6) PlaceHodel:@"客户姓名" Title:@""];
        _nameText.backgroundColor = [UIColor colorWithHexString:@"#EFF0F5"];
        typeof(self) weakSelf = self;
        _nameText.tfBlock = ^(NSString *tfStr){
            if (weakSelf.chooseblock) {
                weakSelf.chooseblock(0,tfStr);
            }
        };
    }
    return _nameText;
}
-(TextFiledView *)lianXiText//联系人
{
    if (!_lianXiText) {
        _lianXiText = [[TextFiledView alloc]initWithFrame:CGRectMake(35*screenW_6,CGRectGetMaxY(_nameText.frame)+10*screenW_6,SCREENW-70*screenW_6, 40*screenW_6) PlaceHodel:@"联系人" Title:@""];
        _lianXiText.backgroundColor = [UIColor colorWithHexString:@"#EFF0F5"];
         typeof(self) weakSelf = self;
        _lianXiText.tfBlock = ^(NSString *tfStr){
            if (weakSelf.chooseblock) {
                weakSelf.chooseblock(1,tfStr);
            }
        };
    }
    return _lianXiText;
}
-(TextFiledView *)phoneText//联系电话
{
    if (!_phoneText) {
        _phoneText = [[TextFiledView alloc]initWithFrame:CGRectMake(35*screenW_6,CGRectGetMaxY(_lianXiText.frame)+10*screenW_6,SCREENW-70*screenW_6, 40*screenW_6) PlaceHodel:@"联系电话" Title:@""];
        _phoneText.backgroundColor = [UIColor colorWithHexString:@"#EFF0F5"];
        _phoneText.inputTf.keyboardType = UIKeyboardTypeNumberPad;
         typeof(self) weakSelf = self;
        _phoneText.tfBlock = ^(NSString *tfStr){
            if (weakSelf.chooseblock) {
                weakSelf.chooseblock(2,tfStr);
            }
        };
    }
    return _phoneText;
}
-(TextFiledView *)addressText//地址
{
    if (!_addressText) {
        _addressText = [[TextFiledView alloc]initWithFrame:CGRectMake(35*screenW_6,CGRectGetMaxY(_phoneText.frame)+10*screenW_6,SCREENW-70*screenW_6, 40*screenW_6) PlaceHodel:@"地址" Title:@""];
        _addressText.backgroundColor = [UIColor colorWithHexString:@"#EFF0F5"];
         typeof(self) weakSelf = self;
        _addressText.tfBlock = ^(NSString *tfStr){
            if (weakSelf.chooseblock) {
                weakSelf.chooseblock(3,tfStr);
            }
        };
    }
    return _addressText;
}

-(void)addSerchView//添加查询
{
     _resetLab = [TomamaUI createLabel:CGRectMake(0,280*screenW_6-40*screenW_6,SCREENW/2, 40*screenW_6) textAligment:1 font:[UIFont systemFontOfSize:15*screenW_6] textColor:[UIColor colorWithHexString:@"#999999"] text:@"重置"];
    _resetLab.userInteractionEnabled = YES;
    [self addSubview:_resetLab];
    
    _searchLab = [TomamaUI createLabel:CGRectMake(SCREENW/2+1*screenW_6,280*screenW_6-40*screenW_6,SCREENW/2, 40*screenW_6) textAligment:1 font:[UIFont systemFontOfSize:15*screenW_6] textColor:[UIColor colorWithHexString:@"#55aee9"] text:@"查询"];
    _searchLab.userInteractionEnabled = YES;
    [self addSubview:_searchLab];
    
    [self addSubview:[ToolViewViewController addCellLineLab:CGRectMake(0,self.frame.size.height-41*screenW_6, SCREENW, 1*screenW_6)]];
    
    [self addSubview:[ToolViewViewController addCellLineLab:CGRectMake(SCREENW/2,280*screenW_6-41*screenW_6, 1*screenW_6, 41*screenW_6)]];
    
    UITapGestureRecognizer *resetTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(resetSelectTap)];
    [_resetLab addGestureRecognizer:resetTap];
    
    UITapGestureRecognizer *editTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(editSelectTap)];
    [_searchLab addGestureRecognizer:editTap];
    
}
-(void)resetSelectTap
{
    if (self.chooseblock) {
        self.chooseblock(4,@"重置");
    }
}
-(void)editSelectTap
{
    if (self.chooseblock) {
        self.chooseblock(5,@"查询");
    }
}

@end
